package Application;

import java.awt.*;
import java.util.*;
import javax.swing.*;


public class GeneralMessage
{
	public static final String applicationname = "ColorTangram";
	public static final String applicationversion = "1.3.0.0";
	public static final String applicationby = "Sunflower";
	public static final String applicationlastemodified = "2015/11/17";
	public static final String applicationcreationdate = "2015/03/01 06:38:15";

	public static final String locallanguage = Locale.getDefault().getLanguage() + "_" + java.util.Locale.getDefault().getCountry();
	public static final Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();
	public static final String osname = System.getProperty("os.name");

	public static final String[] SupportLanguage = {"en_US", "zh_CN", "zh_TW"};

	public static String LanguageString(String ThisLanguage, String ThisClass, String ThisVariable, Object... ThisOther)
	{
		int i;
		boolean d = false;

		for(i = 0; i < SupportLanguage.length; i ++)
			if(ThisLanguage.equals(SupportLanguage[i]))
				d = true;

		if(!d)
			ThisLanguage = SupportLanguage[0];

		switch(ThisLanguage)
		{
			case "en_US":
				switch(ThisClass)
				{
					case "Application.MainWindow":
						switch(ThisVariable)
						{
							case "MenuItemNew":
								return "New...";
							case "MenuItemOpen":
								return "Open...";
							case "MenuItemClose":
								return "Close";
							case "MenuItemSave":
								return "Save";
							case "MenuItemSave...":
								return "Save...";
							case "MenuItemSaveAs":
								return "Save As...";
							case "MenuItemRevert":
								return "Revert...";
							case "MenuItemCopyScreenShot":
								return "Copy Screen Shot";
							case "MenuItemAddTangram":
								return "Add Tangram";
							case "MenuItemRemoveTangram":
								return "Remove Tangram";
							case "MenuItemQuit":
								return "Quit " + LanguageString(ThisLanguage, ThisClass, "GameName");
							case "MenuItemZoomIn":
								return "Zoom in";
							case "MenuItemZoomOut":
								return "Zoom out";
							case "MenuItemRotateLeft":
								return "Rotate Left";
							case "MenuItemRotateRight":
								return "Rotate Right";
							case "MenuItemVerticalInvert":
								return "Vertical Invert";
							case "MenuItemHorizontalInvert":
								return "Horizontal Invert";
							case "MenuItemChangeColor":
								return "Change Color...";
							case "MenuItemHide":
								return "Hide";
							case "MenuItemShowHiddenTangram":
								return "Show Hidden Tangram";
							case "MenuItemMinimize":
								return "Minimize";
							case "MenuItemMaximize":
								return osname.startsWith("Mac OS") ? "Zoom" : "Maximize";
							case "MenuItemAbout":
								return "About " + LanguageString(ThisLanguage, ThisClass, "GameName");
							case "MenuItemHelp":
								return LanguageString(ThisLanguage, ThisClass, "GameName") + " Help";
							case "MenuGame":
								return "Game";
							case "MenuControl":
								return "Control";
							case "MenuView":
								return "View";
							case "MenuWindow":
								return "Window";
							case "MenuHelp":
								return "Help";
							default:
								break;
						}
						break;
					default:
						break;
				}
				break;
			case "zh_CN":
				switch(ThisClass)
				{
					case "Application.MainWindow":
						switch(ThisVariable)
						{
							case "MenuItemNew":
								return "新建…";
							case "MenuItemOpen":
								return "打开…";
							case "MenuItemClose":
								return "关闭";
							case "MenuItemSave":
								return osname.startsWith("Mac OS") ? "存储" : "保存";
							case "MenuItemSave...":
								return osname.startsWith("Mac OS") ? "存储…" : "保存…";
							case "MenuItemSaveAs":
								return osname.startsWith("Mac OS") ? "存储为…" : "另存为…";
							case "MenuItemRevert":
								return osname.startsWith("Mac OS") ? "复原…" : "还原…";
							case "MenuItemCopyScreenShot":
								return osname.startsWith("Mac OS") ? "拷贝屏幕快照" : "复制屏幕截图";
							case "MenuItemAddTangram":
								return "添加七巧板";
							case "MenuItemRemoveTangram":
								return "移除七巧板";
							case "MenuItemQuit":
								return "退出" + LanguageString(ThisLanguage, ThisClass, "GameName");
							case "MenuItemZoomIn":
								return "放大";
							case "MenuItemZoomOut":
								return "缩小";
							case "MenuItemRotateLeft":
								return "向左旋转";
							case "MenuItemRotateRight":
								return "向右旋转";
							case "MenuItemVerticalInvert":
								return "垂直翻转";
							case "MenuItemHorizontalInvert":
								return "水平翻转";
							case "MenuItemChangeColor":
								return "更改颜色…";
							case "MenuItemHide":
								return "隐藏";
							case "MenuItemShowHiddenTangram":
								return "显示隐藏的七巧板";
							case "MenuItemMinimize":
								return "最小化";
							case "MenuItemMaximize":
								return osname.startsWith("Mac OS") ? "缩放" : "最大化";
							case "MenuItemAbout":
								return "关于" + LanguageString(ThisLanguage, ThisClass, "GameName");
							case "MenuItemHelp":
								return LanguageString(ThisLanguage, ThisClass, "GameName") + "帮助";
							case "MenuGame":
								return "游戏";
							case "MenuControl":
								return "控制";
							case "MenuView":
								return osname.startsWith("Mac OS") ? "显示" : "查看";
							case "MenuWindow":
								return "窗口";
							case "MenuHelp":
								return "帮助";
							default:
								break;
						}
						break;
					default:
						break;
				}
				break;
			case "zh_TW":
				switch(ThisClass)
				{
					case "Application.MainWindow":
						switch(ThisVariable)
						{
							case "MenuItemNew":
								return osname.startsWith("Mac OS") ? "新增⋯" : "開新檔案⋯";
							case "MenuItemOpen":
								return osname.startsWith("Mac OS") ? "打開⋯" : "開啟檔案⋯";
							case "MenuItemClose":
								return "關閉";
							case "MenuItemSave":
								return osname.startsWith("Mac OS") ?  "儲存" : "儲存檔案";
							case "MenuItemSave...":
								return osname.startsWith("Mac OS") ? "儲存⋯" : "儲存檔案⋯";
							case "MenuItemSaveAs":
								return osname.startsWith("Mac OS") ? "儲存為⋯" : "另存新檔⋯";
							case "MenuItemRevert":
								return "回復";
							case "MenuItemCopyScreenShot":
								return osname.startsWith("Mac OS") ? "拷貝螢幕快照⋯" : "複製螢幕截圖⋯";
							case "MenuItemAddTangram":
								return "添加七巧板";
							case "MenuItemRemoveTangram":
								return "移除七巧板";
							case "MenuItemQuit":
								return "結束" + LanguageString(ThisLanguage, ThisClass, "GameName");
							case "MenuItemZoomIn":
								return "放大";
							case "MenuItemZoomOut":
								return "縮小";
							case "MenuItemRotateLeft":
								return "向左旋轉";
							case "MenuItemRotateRight":
								return "向右旋轉";
							case "MenuItemVerticalInvert":
								return "垂直翻轉";
							case "MenuItemHorizontalInvert":
								return "水平翻轉";
							case "MenuItemChangeColor":
								return "更改顏色⋯";
							case "MenuItemHide":
								return "隱藏";
							case "MenuItemShowHiddenTangram":
								return "顯示隱藏的七巧板";
							case "MenuItemMinimize":
								return osname.startsWith("Mac OS") ? "縮到最小" : "最小化";
							case "MenuItemMaximize":
								return osname.startsWith("Mac OS") ? "縮放" : "最大化";
							case "MenuItemAbout":
								return "關於" + LanguageString(ThisLanguage, ThisClass, "GameName");
							case "MenuItemHelp":
								return osname.startsWith("Mac OS") ? LanguageString(ThisLanguage, ThisClass, "GameName") + "輔助說明" : LanguageString(ThisLanguage, ThisClass, "GameName") + "說明";
							case "MenuGame":
								return "遊戲";
							case "MenuControl":
								return "控制";
							case "MenuView":
								return osname.startsWith("Mac OS") ? "顯示方式" : "檢視";
							case "MenuWindow":
								return "視窗";
							case "MenuHelp":
								return osname.startsWith("Mac OS") ? "輔助說明" : "說明";
							default:
								break;
						}
						break;
					default:
						break;
				}
				break;
			default:
				break;
		}

		switch(ThisLanguage)
		{
			case "en_US":
				switch(ThisVariable)
				{
					case "GameName":
						return "Color Tangram";
					case "ApplicationVersion":
						return LanguageString(ThisLanguage, ThisClass, "GameName") + " " + applicationversion;
					case "ApplicationBy":
						return "Created By " + applicationby;
					case "ApplicationLasteModified":
						return "Laste Modified " + applicationlastemodified;
					case "ApplicationCreationDate":
						return "Creation Date " + applicationcreationdate;
					case "RevertMessageText":
						return "Revert current file to last opened?";
					case "ProblemMessageText":
						return LanguageString(ThisLanguage, ThisClass, "GameName") + " has experienced an problem!\nThrows in \"" + ThisClass + "\":\n\n" + ThisOther[0];
					case "HelpMessageText":
						return "Tangram Description:\n\nTangram is a puzzle game, you can use a tangram spell out a pattern, if you use more than vice tangram, they may even spell out a picture\n\n\n" + LanguageString(ThisLanguage, ThisClass, "MenuItemHelp") + " :\n\nYou can be moved by dragging the puzzle can be selected via the menu bar rotate, flip, zoom and change tangram color.\nIn addition, the game also supports saving schedule, you can save your progress through the menu bar, read progress, create new progress and other features.";
					case "OKOption":
						return "OK";
					case "CancelOption":
						return "Cancel";
					case "AbortOption":
						return "Abort";
					default:
						break;
				}
				break;
			case "zh_CN":
				switch(ThisVariable)
				{
					case "GameName":
						return "彩色七巧板";
					case "ApplicationVersion":
						return LanguageString(ThisLanguage, ThisClass, "GameName") + " " + applicationversion;
					case "ApplicationBy":
						return "创始人 " + applicationby;
					case "ApplicationLasteModified":
						return "最后修改 " + applicationlastemodified;
					case "ApplicationCreationDate":
						return "创建日期 " + applicationcreationdate;
					case "RevertMessageText":
						return "恢复当前文件到最后打开时的样子？";
					case "ProblemMessageText":
						return LanguageString(ThisLanguage, ThisClass, "GameName") + "出现了问题！\n抛出在“" + ThisClass + "”：\n\n" + ThisOther[0];
					case "HelpMessageText":
						return "七巧板介绍：\n\n七巧板是一个智力游戏，你可以用一副七巧板拼出一个图案，如果使用多副七巧板，甚至还有可能拼出一幅画。\n\n\n" + LanguageString(ThisLanguage, ThisClass, "MenuItemHelp") + "：\n\n你可以通过拖动七巧板来移动，可以通过菜单栏选择旋转、翻转、缩放七巧板以及更改七巧板颜色。\n此外，游戏的进度还支持保存，你可以通过菜单栏选择保存进度、读取进度、创建新的进度和其它功能。";
					case "OKOption":
						return osname.startsWith("Mac OS") ? "好" : "确定";
					case "CancelOption":
						return "取消";
					case "AbortOption":
						return osname.startsWith("Mac OS") ? "结束" : "终止";
					default:
						break;
				}
				break;
			case "zh_TW":
				switch(ThisVariable)
				{
					case "GameName":
						return "彩色七巧板";
					case "ApplicationVersion":
						return LanguageString(ThisLanguage, ThisClass, "GameName") + " " + applicationversion;
					case "ApplicationBy":
						return "創始人 " + applicationby;
					case "ApplicationLasteModified":
						return "最後修改 " + applicationlastemodified;
					case "ApplicationCreationDate":
						return "創建日期 " + applicationcreationdate;
					case "RevertMessageText":
						return osname.startsWith("Mac OS") ? "回復當前檔案到最後打開時的樣子？" : "回復當前檔案到最後開啟時的樣子？";
					case "ProblemMessageText":
						return LanguageString(ThisLanguage, ThisClass, "GameName") + "出現了問題！\n拋出在“" + ThisClass + "”：\n\n" + ThisOther[0];
					case "HelpMessageText":
						return "七巧板介紹：\n\n七巧板是一個智力遊戲，你可以用一副七巧板拼出一個圖案，如果使用多副七巧板，甚至還有可能拼出一幅畫。\n\n\n" + LanguageString(ThisLanguage, ThisClass, "MenuItemHelp") + "：\n\n你可以通過拖動七巧板來移動，可以通過菜單欄選擇旋轉、翻轉、縮放七巧板以及更改七巧板顏色。\n此外，遊戲的進度還支持儲存，你可以通過菜單欄選擇儲存進度、讀取進度、創建新的進度和其它功能。";
					case "OKOption":
						return osname.startsWith("Mac OS") ? "好" : "確定";
					case "CancelOption":
						return "取消";
					case "AbortOption":
						return osname.startsWith("Mac OS") ? "結束" : "終止";
					default:
						break;
				}
				break;
			default:
				break;
		}

		return null;
	}

	public static int ShowMessage(Component ThisComponent, Object ThisMessage, String ThisTitle, int ThisType, String... ThisOption)
	{
		int i;

		for(i = 0; i < ThisOption.length; i ++)
			ThisOption[i] = LanguageString(locallanguage, "", ThisOption[i] + "Option");

		return JOptionPane.showOptionDialog(ThisComponent, ThisMessage, ThisTitle, JOptionPane.YES_OPTION, ThisType, null, ThisOption, ThisOption[ThisOption.length - 1]);
	}

	public static void ReturnException(Exception ThisException, Component ThisComponent)
	{
		String ThrowClass = ThisException.getStackTrace()[0].getClassName();

		ThisException.printStackTrace();
 
		if(ShowMessage(ThisComponent, LanguageString(locallanguage, ThrowClass, "ProblemMessageText", ThisException), LanguageString(locallanguage, ThrowClass, "GameName"), JOptionPane.ERROR_MESSAGE, "Abort", "OK") == 0)
			System.exit(1);
	}
}
